package data;

import models.ReadingSheet;
import models.User;
import play.cache.Cache;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
import play.test.Fixtures;

/**
 * Things to do before application start.
 * @author Elisa
 *
 */
@OnApplicationStart
public class Bootstrap extends Job {

	/**
	 * Load data to test.
	 */
	@Override
	public void doJob() {
		// Check if the database is empty
		if (ReadingSheet.count() == 0) {
			Fixtures.loadModels("data/initial-data.yml");
		}
		
		User user = User.find("byPseudo", "flo").first();
		Cache.set("user", user, "120mn");
	}

}
